<template>
	<view class="subassembly_goods">
	    <view class="goods_part" v-for="(item, i) in list" :key="i" 
              :class="{'showBlock': list.length === 2 }">
	        <view class="goods_picture" @click="toPge(item)" >
				<image id="img" :src="item.cover || '/static/image/card1.png'" ></image>	
				<view class="work_time">
					<image src="/static/image/time_icon.png"></image>
					<text>{{item.worktime || '暂无营业时间'}}</text>
				</view>
			</view>
	        <view class="goods_text pr">
	            <p >{{item.name  || '暂无商家名称'}}</p>
				
				<view class="address">
					<view>
						<image :src="location_img"></image>
					</view>
						<view class="address_name one-n">{{ item.address  || '暂无商家地址'}}</view>
				</view>
					<span class="addressdistnace one-t">{{item.distance}}km</span>
	            
	        </view>
	    </view>
	</view>
</template>

<script>
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		name:"seller-list",
		data() {
			return {
				location_img: this.imgUrl + 'location_icon.png'
			};
		},
		props: {
		    sellers_data: {
		        type: Array,
		        default: ()=>[],
		    },
		},
		computed: {
			list() {
				let arr = this.newsellers(this.sellers_data);
				if (!arr) {
					arr = []
				}
				return arr ;
			},
		},
		methods: {
			newsellers(list) {
			    if (list && list.length > 0 && list.length != 2) {
			        let total = { 0: [], 1: [], length: 2 };
			        list.forEach((item, index) => {
			            total[index % 2].push(item);
			        });
			        const newList = [].concat(...Array.from(total));
			        return newList;
			    }
				if (list.length == 2) {
					return list;
				}
			},
			toPge(item) {
				this.$emit("jumpDetail",item)
			},
		},
	}
</script>

<style lang="scss" scoped>
	.showBlock:nth-child(2) {
		display: block!important;
	}
	
	@import  './index.scss';

</style>
